package mailGetter;

import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;

public class MailGetter {
	
		Store store;
		
	
	MailGetter (HashMap<String, String> AccessData) {
		
		String host  = AccessData.get("hostname");
		String hostType = AccessData.get("hostType");
		String username = AccessData.get("username");
		String password = AccessData.get("password");
		
		// Create empty properties
	    Properties props = new Properties();

	    // Get session
	    Session session = Session.getDefaultInstance(props, null);

	    // Get the store
	    Store mailStore = null;
		try {
			mailStore = session.getStore(hostType);
		} catch (NoSuchProviderException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	    // Connect to store
	    try {
	    	mailStore.connect(host, username, password);
		} catch (MessagingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	    
	    store = mailStore;
	}
	 
}
